//
//  TTbottomBarView.m
//  TTWeibo
//
//  Created by 陶宏路 on 16/7/30.
//  Copyright © 2016年 陶路路. All rights reserved.
//

#import "TTbottomBarView.h"

@interface TTbottomBarView ()

@property (nonatomic,strong) UIButton * leftButton;
@property (nonatomic,strong) UIButton * centerButton;
@property (nonatomic,strong) UIButton * rightButton;

@end
@implementation TTbottomBarView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self setUpUI];
        self.backgroundColor = RANDOMCOLOR;
    }
    
    return self;
}

-(void)setUpUI{
    
    self.leftButton = [self getButonWith:@"转发" img:@"timeline_icon_retweet"];
    self.centerButton = [self getButonWith:@"评论" img:@"timeline_icon_comment"];
    self.rightButton = [self getButonWith:@"转发" img:@"timeline_icon_unlike"];
    [self addSubview:self.leftButton];
    [self addSubview:self.centerButton];
    [self addSubview:self.rightButton];
    
    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.leading.bottom.equalTo(self);
        make.width.equalTo(self.centerButton);
    }];
    
    [self.centerButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.leftButton);
        make.leading.equalTo(self.leftButton.mas_trailing);
        make.width.height.equalTo(self.rightButton);
    }];
    
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.equalTo(self.leftButton);
        make.trailing.equalTo(self.mas_trailing);
        make.leading.equalTo(self.centerButton.mas_trailing);
        make.width.height.equalTo(self.leftButton);
    }];
    
}

-(UIButton*)getButonWith:(NSString *)title img:(NSString *)img{
    
    UIButton * button = [[UIButton alloc]init];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:img] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:@"timeline_card_bottom_background"] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:@"timeline_card_bottom_background_highlighted"] forState:UIControlStateHighlighted];
    return button;
}
@end
